<template>
  <div class="myAccount2">
    <!-- 银行卡弹窗 -->
    <el-dialog title="添加银行卡" :visible.sync="tanShow1" width="30%" center>
      <el-form
        ref="form1"
        :rules="rules1"
        :model="form1"
        label-width="135px"
        label-position="left"
      >
        <el-form-item label="真实姓名：" prop="name">
          <el-input
            v-model.trim="form1.name"
            maxlength="10"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="身份证号：" prop="idCard">
          <el-input
            v-model.trim="form1.idCard"
            maxlength="18"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="银行卡号：" prop="accountNumber">
          <el-input
            v-model.trim="form1.accountNumber"
            maxlength="30"
            clearable
            onkeyup="this.value=this.value.replace(/\D/g,'')"
          ></el-input>
        </el-form-item>
        <el-form-item label="银行预留手机号：" prop="phoneNumber">
          <el-input
            v-model.trim="form1.phoneNumber"
            maxlength="11"
            clearable
            onkeyup="this.value=this.value.replace(/\D/g,'')"
          ></el-input>
        </el-form-item>
        <el-form-item label="手机验证码：" prop="code">
          <div class="divFlex">
            <el-input
              v-model.trim="form1.code"
              placeholder="验证码"
              class="enrollInp"
              clearable
              style="width: 65%; margin-right: 10px"
              maxlength="10"
              onkeyup="this.value=this.value.replace(/\D/g,'')"
            ></el-input>
            <el-button
              type="primary"
              :disabled="gain.flag"
              @click="sendCodeFun('form1')"
            >
              {{ gain.title }}</el-button
            >
          </div>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="ifShowTan1(false)">取 消</el-button>
        <el-button
          type="primary"
          @click="addUserFun1('form1', 'BANKCARD')"
          :disabled="addBankButton"
          v-loading.fullscreen.lock="fullscreenLoading"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- 支付宝弹窗 -->
    <el-dialog title="添加支付宝" :visible.sync="tanShow2" width="30%" center>
      <el-form
        ref="form2"
        :rules="rules2"
        :model="form2"
        label-width="110px"
        label-position="left"
      >
        <el-form-item label="支付宝姓名：" prop="name">
          <el-input
            v-model.trim="form2.name"
            maxlength="10"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="支付宝账号：" prop="accountNumber">
          <el-input
            v-model.trim="form2.accountNumber"
            onkeyup="this.value=this.value.replace(/[, ]/g,'')"
            maxlength="30"
            clearable
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="ifShowTan2(false)">取 消</el-button> -->
        <el-button @click="tanShow2 = false">取 消</el-button>
        <el-button
          type="primary"
          @click="addUserFun1('form2', 'ALIPAY')"
          :disabled="showButton"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 支付宝编辑弹窗 -->
    <el-dialog title="编辑支付宝" :visible.sync="tanShow3" width="30%" center>
      <el-form
        ref="form3"
        :rules="rules3"
        :model="form3"
        label-width="110px"
        label-position="left"
      >
        <el-form-item label="支付宝姓名：" prop="name">
          <el-input
            v-model.trim="form3.name"
            maxlength="20"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="支付宝账号：" prop="accountNumber">
          <el-input
            v-model.trim="form3.accountNumber"
            maxlength="30"
            clearable
            onkeyup="this.value=this.value.replace(/\D/g,'')"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="tanShow3 = false">取 消</el-button>
        <el-button type="primary" @click="addUserFun3('form3')"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 提现弹窗 -->
    <el-dialog
      title="提现"
      :visible.sync="withdraw"
      width="30%"
      center
      :before-close="withdrawClose"
    >
      <el-form
        ref="elForm"
        :model="formData"
        :rules="rules"
        size="medium"
        label-width="110px"
        label-position="left"
      >
        <el-form-item label="账号余额" prop="field101">
          <el-input
            v-model.trim="formData.field101"
            placeholder=""
            :disabled="true"
            clearable
            :style="{ width: '100%' }"
          ></el-input>
        </el-form-item>
        <el-form-item label="金额" prop="mobile">
          <el-input
            v-model.trim="formData.mobile"
            placeholder="请输入金额"
            maxlength="7"
            show-word-limit
            clearable
            @input="mobileChange"
            onkeyup="this.value=this.value.replace(/[, ]/g,'')"
            :style="{ width: '100%' }"
          ></el-input>
        </el-form-item>

        <el-form-item label="提现账号" prop="field102">
          <el-select
            :style="{ width: '100%' }"
            v-model="formData.field102"
            placeholder="请选择提现账号"
          >
            <el-option
              v-for="item in field102Options"
              :key="item.value"
              :label="item.accountNumber"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="验证码：" prop="code">
          <div class="divFlex">
            <el-input
              v-model.trim="formData.code"
              placeholder="验证码"
              class="enrollInp"
              clearable
              style="width: 65%; margin-right: 10px"
              maxlength="10"
              onkeyup="this.value=this.value.replace(/\D/g,'')"
            ></el-input>
            <el-button
              type="primary"
              :disabled="fixed.flag"
              @click="withdrawSendCodeFun"
            >
              {{ fixed.title }}</el-button
            >
          </div>
        </el-form-item>
        <!-- <el-form-item label="手续费">
          <span>{{ formData.Handling }}</span>
        </el-form-item> -->
        <el-form-item label="手续费金额">
          <span>{{ formData.HandlingMoney }}</span>
        </el-form-item>
        <el-form-item label="实际到账金额">
          <span>{{ formData.actualMoney }}</span>
        </el-form-item>
      </el-form>

      <div slot="footer">
        <el-button @click="withdrawClose">取消</el-button>
        <el-button
          type="primary"
          @click="handelConfirm"
          :loading="withdrawalLoading"
          :disabled="showButton || submitMoneyButton"
          >确定</el-button
        >
      </div>
    </el-dialog>

    <div :class="userCode=='用户'?'topDiv':'topDiv2'">
      <div>
        <div class="line-bottom">
          <p class="title" style="border: 0px">
            <img src="../../../assets/images/sf.png" alt />
            <span class="account-title">我的信息</span>
          </p>
          <div class="accoutTop">
            <div>
              <el-avatar :size="60" :src="userParam.userimg"> </el-avatar>
            </div>
            <div class="accoutTop-left">
              <div style="margin-bottom: 10px">
                <span class="accountName"
                  >下午好，{{ userDataParma.userName }}</span
                >
                <!-- <span class="accountName"
                  >下午好，{{ userParam.userName }}</span
                > -->
                <span class="color66">提现看头像，安全有保证</span>
              </div>
              <div class="accountPhone">
                <span>
                  账户名： {{ userDataParma.userName }}
                  <img src="@/assets/img/phone2.png" alt style="height: 16px" />
                </span>
                <span
                  style="
                    margin-left: 10px;
                    border-left: rgb(231, 228, 231) 1px solid;
                    padding-left: 10px;
                  "
                >
                  登录时间：<span>{{ LoginTime }}</span></span
                >
              </div>
            </div>
            <!-- <div class="accoutTop-right">
              <div class="accountBox">
                <vue-qr
                  v-show="qrcode"
                  :text="qrcode"
                  :margin="20"
                  :size="150"
                ></vue-qr>
                <p>{{ Invitation }}</p>
              </div>
            </div> -->
          </div>
        </div>
        <div :class="userCode=='用户'?'line-bottom2':'line-bottom1'">
          <p class="title" style="border: 0px">
            <img src="../../../assets/images/qb.png" alt style="height:35px;width:37px"/>

            <span class="account-title">我的账户</span>
          </p>
          <div class="account">
            <el-row>
              <el-col :span="2" style="width: 300px">
                <span
                  class="Info"
                  style="margin-right: 10px; color: #747774; font-size: 18px"
                  >账户余额</span
                >
                <!-- <span>
                  <el-button type="text" @click="ShowMoney">
                    <img
                      src="../../../assets/images/y22.png"
                      v-show="eye"
                      style="height: 25px"
                      alt
                    />
                    <img
                      style="height: 25px"
                      src="../../../assets/images/y11.png"
                      v-show="!eye"
                      alt
                    />
                  </el-button>
                </span> -->
                <img
                  src="../../../assets/images/y11.png"
                  v-show="show"
                  alt
                  @click="change"
                />
              </el-col>
            </el-row>
            <el-row style="display: flex; align-items: center">
              <el-col :span="5">
                <p class="Brand" style="color: rgb(73, 130, 237)">
                  ￥<span style="font-size: 30px"
                    >{{ amount || 0 }}
                    <span style="font-size: 16px; font-weight: 700">元</span>
                  </span>
                </p>
                <!-- <p class="Brand" style="color: rgb(73, 130, 237)">
                  ￥<span style="font-size: 30px" v-show="eye"
                    >{{ amount || 0 }}
                    <span style="font-size: 16px; font-weight: 700">元</span>
                  </span>
                  <span style="font-size: 30px" v-show="!eye">***</span>
                </p> -->
              </el-col>
              <el-col :span="9" class="buttonBox" v-if="userCode != '租户'">
                <el-button
                  type="primary"
                  style="margin-right: 50px"
                  @click="moneyT"
                  >提现</el-button
                >
                <el-button type="primary" @click="ifShowTan1(true)"
                  >添加银行卡</el-button
                >
                <el-button
                  type="primary"
                  @click="ifShowTan2(true, false)"
                  style="margin-left: 60px"
                  >添加支付宝</el-button
                >
              </el-col>
            </el-row>
          </div>
        </div>

        <div v-if="tabStatus == 1&&userCode=='用户'">
          <div>
            <p class="title">
              <img
                src="../../../assets/images/yhk.png"
                alt
                style="height:35px;width:37px"
              />
              <span class="account-title">我的账户</span>
            </p>
            <el-row :gutter="40">
              <el-col
                v-for="(item, index) in bank"
                :key="index"
                :span="6"
                style="margin-bottom: 25px"
              >
                <div
                  :class="
                    item.withdrawalAccountType == 'ALIPAY'
                      ? 'Alipay'
                      : 'bankBox'
                  "
                >
                  <!-- bankBox -->
                  <el-row>
                    <el-col :span="4" style="margin: 0px 10px">
                      <img
                        v-if="item.withdrawalAccountType == 'ALIPAY'"
                        src="../../../assets/images/zfblist.png"
                        alt
                        style="width: 45px; height: 45px"
                      />
                      <div class="aaBox" v-else>
                        <div class="aa"></div>
                      </div>
                    </el-col>

                    <el-col :span="18">
                      <div
                        style="margin-bottom: 5px"
                        v-show="item.withdrawalAccountType == 'ALIPAY'"
                      >
                        {{ item.accountName }}
                      </div>
                      <div
                        class="hint"
                        v-if="item.withdrawalAccountType != 'ALIPAY'"
                      >
                        尾号
                        {{ item.accountNumber }}
                        <span class="card-type">
                          <span class="name">储蓄卡</span>
                        </span>
                      </div>
                      <div v-else>{{ item.accountNumber }}</div>
                    </el-col>
                  </el-row>
                  <el-row
                    style="margin-top: 55px; display: flex"
                    v-if="item.withdrawalAccountType == 'ALIPAY'"
                  >
                    <el-col :span="14" style="padding-left: 2px">
                      <el-button
                        type="text"
                        class="fontSize"
                        style="text-decoration: underline"
                        @click="clickModification(item)"
                        >编辑</el-button
                      >
                    </el-col>
                    <el-col :span="10">
                      <div class="rightbox">
                        <div class="iconbox">
                          <i class="el-icon-delete deletedIcon"></i>
                        </div>
                        <el-button
                          type="text"
                          class="fontSize"
                          @click="clickDelete(item.id, item.accountName)"
                          >删除</el-button
                        >
                      </div>
                    </el-col>
                  </el-row>
                  <el-row style="margin-top: 62px; display: flex" v-else>
                    <el-col :span="14" style="padding-left: 2px">
                      <el-button
                        type="text"
                        style="
                          font-size: 15px;
                          text-decoration: underline;
                          color: #fff;
                          cursor: auto;
                        "
                        >已认证</el-button
                      >
                    </el-col>
                    <el-col :span="10">
                      <div class="rightbox">
                        <div class="iconbox">
                          <img
                            src="@/assets/img/delete.png"
                            alt=""
                            style="
                              height: 30px;
                              width: 30px;
                              display: inline-block;
                            "
                          />
                        </div>
                        <el-button
                          type="text"
                          class="fontSize"
                          style="color: #fff; font-weight: 404"
                          @click="clickDelete(item.id, item.accountNumber)"
                          >删除</el-button
                        >
                      </div>
                    </el-col>
                  </el-row>
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
      </div>
    </div>
    <!-- 公告弹窗 -->
    <Dialog
      ref="mychild"
      @AddAnnouncement="AddAnnouncement"
      :uelLocation="uelLocation"
    />
    <!-- 实名弹窗 -->
    <el-dialog title="实名" :visible.sync="realNameShow" width="30%" center>
      <el-form
        ref="realNameElForm"
        :model="formData5"
        :rules="rules5"
        size="medium"
        label-width="100px"
        label-position="left"
      >
        <el-form-item label="真实姓名" prop="field101">
          <el-input
            v-model="formData5.field101"
            placeholder="请输入真实姓名"
            clearable
            onkeyup="this.value=this.value.replace(/[, ]/g,'')"
            maxlength="10"
            :style="{ width: '100%' }"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="field102">
          <el-input
            v-model="formData5.field102"
            placeholder="请输入身份证号"
            clearable
            maxlength="18"
            :style="{ width: '100%' }"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="realNameShow = false">取消</el-button>
        <el-button type="primary" @click="handelConfirm5">确定</el-button>
      </div>
    </el-dialog>
    <!-- 提现状态关闭富文本弹窗 -->
    <el-dialog
      title="消息"
      :visible.sync="WithdrawalStatusShow"
      width="50%"
      center
    >
      <div style="height: 400px">
        <quill-editor
          ref="text"
          v-model="richText.withdrawContent"
          disabled
          style="height: 350px"
          :options="editorOption"
        >
        </quill-editor>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { quillEditor } from "vue-quill-editor";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import {
  selectCapUserWalletById,
  insertCapUserWithdrawalAccountBank,
  bankAPI,
  deleteCapUserWithdrawalAccountById,
  updateCapUserWithdrawalAccount,
  getAmountFeeInfo,
  withdrawbankCard,
  getTransferAccount,
  bankCardAPI,
  Verification,
} from "@/api/finance/index.js";
import VueQr from "vue-qr";
import { updateRUser } from "@/api/base/index.js";
import { getUserProfile, selectByTeamUserByOne } from "@/api/system/user";
import {
  getInfo,
  selectByInvitationCodeIsUserId,
  getSetup,
  selectByInvitationConfig,
  selectUserIdByConfig,
} from "@/api/system/index.js";
import { getIdentityAndTopId,getAliDy ,getAliDy1} from "@/api/login.js";
import Dialog from "@/views/components/Dialog.vue";
export default {
  data() {
    // 手机号
    var phonenumber = (rule, value, callback) => {
      if (/^[1][3.4.5.7.8.9][0-9]{9}$/.test(value)) {
        callback();
      } else {
        callback(new Error("手机号码格式不对"));
      }
    };
    // 验证码
    var sendCode = (rule, value, callback) => {
      if (this.sendCodeFlag) {
        callback();
      } else {
        callback(new Error("请获取验证码"));
      }
    };
    // 银行卡号
    var bankCard = (rule, value, callback) => {
      if (/^[1-9]\d{12,18}$/.test(value)) {
        callback();
      } else {
        callback(new Error("银行卡号格式不对"));
      }
    };
    // 身份证号
    var userId = (rule, value, callback) => {
      if (
        /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(
          value
        )
      ) {
        callback();
      } else {
        callback(new Error("身份证号格式不对"));
      }
    };
    //  支付宝账号
    var zfbNumber = (rule, value, callback) => {
      if (
        /^(?:1[3-9]\d{9}|[a-zA-Z\d._-]*\@[a-zA-Z\d.-]{1,10}\.[a-zA-Z\d]{1,20})$/.test(
          value
        )
      ) {
        callback();
      } else {
        callback(new Error("支付宝账号格式不对"));
      }
    };
    return {
      //是否开启提现状态
      withdrawalStateData: 0,
      //富文本
      richText: {
        withdrawContent: "",
      },
      // 富文本弹窗
      WithdrawalStatusShow: false,
      //副文本格式
      editorOption: {
        modules: {
          syntax: {
            highlight: (text) => hljs.highlightAuto(text).value,
          },
          toolbar: [
            [], //去除video即可
          ],
        },
        placeholder: "编辑内容...",
      },
      //获取基础设置是否配置实名
      szrealNameAuth: "", //1必须实名  0不用实名
      //实名按钮
      RealNameButton: false,

      formData5: {
        field101: "",
        field102: "",
      },
      rules5: {
        field101: [
          {
            required: true,
            message: "请输入真实姓名",
            trigger: "change",
          },
        ],
        field102: [
          {
            required: true,
            message: "请输入身份证号",
            trigger: "change",
          },
          {
            pattern:
              /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
            message: "格式错误",
            trigger: "change",
          },
          //   {
          //   pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
          //   message: '格式错误',
          //   trigger: 'change'
          // }
        ],
      },
      //实名弹窗认证
      realNameShow: false,
      //提现手机号参数
      fixed: {
        flag: false,
        title: "发送验证码",
      },
      //当前手机号
      phoneData: "",
      //是否已经实名
      RealNameData: "",
      uelLocation: "",
      //提现按钮的禁用,其他按钮的禁用也共用
      showButton: false,
      //提现loading
      withdrawalLoading: false,
      //用户信息
      userDataParma: [],
      //获取当前时间
      LoginTime: "",
      //睁眼闭眼
      eye: false,
      //二维码链接
      qrcode: "",
      // 提现弹窗显示
      withdraw: false,
      // 提现弹窗参数
      formData: {
        field101: undefined,
        mobile: "",
        field102: undefined,
        Handling: undefined,
        HandlingMoney: 0,
        actualMoney: undefined,
        code: "",
      },
      rules: {
        field101: [],
        mobile: [
          {
            required: true,
            message: "请输入金额",
            trigger: "change",
          },
          {
            pattern:
              /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
            message: "金额格式错误",
            trigger: "change",
          },
        ],
        field102: [
          {
            required: true,
            message: "请选择提现账号",
            trigger: "change",
          },
        ],
        code: [
          {
            required: true,
            message: "输入验证码",
            trigger: "change",
          },
        ],
      },
      field102Options: [
        // {
        //   accountNumber: "选项一",
        //   id: 1,
        // },
      ],
      // 支付宝编辑弹窗
      tanShow3: false,
      // 控制添加银行卡弹窗
      tanShow1: false,
      show: false,
      // 控制添加银行卡弹窗
      tanShow2: false,

      // 添加银行卡弹窗数据
      form1: {
        // name: "牛阳泽", //姓名
        // userId: "1", //用户id
        // phoneNumber: "15517777217", //手机号
        // idCard: "410802198309283512", //身份证
        // code: "123", //验证码
        // accountNumber: "6217002480006284430", //银行卡号
        name: undefined, //姓名
        userId: undefined, //用户id
        phoneNumber: undefined, //手机号
        idCard: undefined, //身份证
        code: undefined, //验证码
        accountNumber: undefined, //银行卡号
      },
      rules1: {
        //   手机号
        phoneNumber: [
          { required: true, message: "手机号不能为空", trigger: "blur" },
          { validator: phonenumber },
        ],
        //   验证码
        // code: [
        //   { required: true, message: "验证码不能为空", trigger: "blur" },
        //   { validator: sendCode },
        // ],
        //   真实姓名
        name: [
          { required: true, message: "真实姓名不能为空", trigger: "blur" },
          { min: 2, message: "最少2位", trigger: "blur" },
        ],
        //   银行卡号
        accountNumber: [
          { required: true, message: "银行卡号不能为空", trigger: "blur" },
          { validator: bankCard },
        ],
        //   身份证号
        idCard: [
          { required: true, message: "身份证号不能为空", trigger: "blur" },
          //  { max: 18, message: "最大18位", trigger: "blur" },
          { validator: userId },
        ],
      },
      // 添加支付宝弹窗数据
      form3: {
        name: undefined, //姓名
        userId: undefined, //用户id
        id: undefined,
        accountNumber: undefined, //手机号
      },
      form2: {
        name: undefined, //姓名
        userId: undefined, //用户id
        accountNumber: undefined, //手机号
      },
      rules2: {
        //   支付宝账号
        accountNumber: [
          { required: true, message: "支付宝账号不能为空", trigger: "change" },
          { validator: zfbNumber },
        ],
        //   支付宝姓名
        name: [
          { required: true, message: "真实姓名不能为空", trigger: "change" },
          { min: 2, message: "最少2位", trigger: "change" },
          {
          pattern:/^[\u4e00-\u9fa5]{0,}$/,
          message: '请输入简体汉字',
          trigger: 'change'
        }
          // 
        ],
      },
      rules3: {
        //   支付宝账号
        accountNumber: [
          { required: true, message: "支付宝账号不能为空", trigger: "change" },
          { validator: zfbNumber },
        ],
        //   支付宝姓名
        name: [
          { required: true, message: "真实姓名不能为空", trigger: "change" },
          { min: 2, message: "最少2位", trigger: "change" },
        ],
      },
      // tab切换状态
      tabStatus: 1, // 1 == 银行卡  0 == 支付宝
      // 定时器
      timer: undefined,
      //  获取验证码按钮
      gain: {
        title: "获取验证码",
        flag: false,
      },
      bank: [],
      bank1: [],
      // 我的支付宝数据
      Alipay: [],
      userId: 0,
      userParam: {},
      amount: "",
      //租户还是平台还是用户
      userCode: "",
      //邀请码
      Invitation: "",
      //防抖
      addBankButton: false,
      //loading加载
      fullscreenLoading: false,
      //层级ID
      topId: {
        // identity:"用户",
        // topId:"200"
      },
      //手续费百分比金额
      HandlingData: "",
      //手续费固定金额
      HandlingMoneyData: "",
      //租户Id
      TenantId: "",
      //是否满足实名未实名的要求
      withdrawState: 0,
      //提现通道是否开通
      WithdrawalChannel: false,
    };
  },
  async created() {
    this.LoginTime = this.moment().format("YYYY-MM-DD HH:mm:ss");
  },
  async mounted() {
    //获取用户ID
    const userID = sessionStorage.getItem("userID");
    this.userId = userID - 0;
    this.TenantId = sessionStorage.getItem("TenantId") - 0;
    //获取是租户还是用户还是平台
    const { data } = await getIdentityAndTopId();
    this.userCode = data.identity;
    this.userData();
    //获取用户个人信息
    const userParma = await getUserProfile();
    // console.log(userParma.data, "用户信息");
    this.userDataParma = userParma.data;

    //公告弹窗
    if (data.identity == "用户") {
      this.AddAnnouncement();
    };

     const setupParam = JSON.parse(sessionStorage.getItem("setupParam"));
      console.log(setupParam, "获取基础设置-账户提现窗口");
      console.log(setupParam.realNameAuth, "");
      this.userParam.userName = setupParam.appName; //名字
      this.userParam.userimg = setupParam.appLogoUrl; //头像
      this.userParam.createTime = setupParam.createTime; //时间
      
  },
  components: { VueQr, Dialog, quillEditor },

  methods: {
    // 实名弹窗函数
    handelConfirm5() {
      this.$refs["realNameElForm"].validate((valid) => {
        if (valid) {
          var reg =
            /^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/;
          console.log(reg.test(this.formData5.field102), "身份证222");
          if (!reg.test(this.formData5.field102)) {
            this.$message({
              message: "请输入正确的身份证号",
              type: "warning",
            });
          } else {
            let param = {
              realname: this.formData5.field101, //真实姓名
              idCard: this.formData5.field102, //身份证号
              uId: this.userId, //id
            };
            console.log(this.formData5, "实名按钮");
            updateRUser(param).then((res) => {
              if (res.code == 200) {
                this.$message({
                  type: "success",
                  message: "实名成功！",
                });
                this.userData();
                this.AddAnnouncement();
                this.realNameShow = false;
              } else {
                this.$message.error("实名失败！");
              }
            });
          }
        }
        // this.close();
      });
    },
    // 提现弹窗函数
    handelConfirm() {
      this.$refs["elForm"].validate(async (valid) => {
        if (valid) {
          var reg =
            /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
          if (!reg.test(this.formData.mobile)) {
            this.$message({
              message: "请输入正确的金额,最多保留2位小数",
              type: "warning",
            });
          } else {
            if (this.formData.mobile < 0.1) {
              this.$message({
                message: "金额不能小于0.1",
                type: "warning",
              });
            } else {
              this.showButton = true;
              setTimeout(() => {
                this.withdrawalLoading = false;
                this.showButton = false;
              }, 5000);
              console.log(this.formData, "提现信息");
              let param = {
                amount: this.formData.mobile, //金额
                withdrawalAccountId: this.formData.field102, //提现账号ID
                userId: this.userId, //当前用户ID
                code: this.formData.code, //验证码
              };
              this.withdrawalLoading = true;
              const res = await bankCardAPI(param);
              console.log(res, "提现信息返回结果");
              if (res.code == "200") {
                this.$message({
                  message: "提交成功",
                  type: "success",
                });

                this.withdrawalLoading = false;
                this.withdraw = false;
                this.userData();
                this.showButton = false;
              } else {
                this.withdrawalLoading = false;
                this.$message.error(res.msg);
                this.showButton = false;
              }
            }
          }
        }
      });
    },
    //公告弹窗和查询是否实名
    async AddAnnouncement() {
      //传递子组件当前的路由；然后调用子组件的事件函数
      this.uelLocation = window.location.pathname.slice(1);
      this.$refs.mychild.gitData();

      //获取邀请码
      const szData = await selectUserIdByConfig();
      if (szData.code == 200) {
        console.log(szData, "获取基础设置++++++++");
        this.szrealNameAuth = szData.data.realNameAuth; //基础设置1必须实名  0不用实名
        this.withdrawalStateData = szData.data.withdrawalState; //是否关闭提现状态  0开启 1关闭
        this.richText.withdrawContent = szData.data.withdrawalDisenableContent; //是否关闭提现状态
        if (!szData.data.withdrawalAccount) {
          this.WithdrawalChannel = false;
          //该提现通道未开通
        } else {
          this.WithdrawalChannel = true;
        }
      } else {
        this.$message.error(szData.msg);
      }

      //查询是否实名认证
      const userRealName = await selectByTeamUserByOne();

      if (userRealName.code == 200) {
        //当前状态1是未实名  0是已实名
        this.RealNameData = userRealName.data.state;
        this.phoneData = userRealName.data.phoneNumber;
        // console.log(userRealName, "用户信息2222");
      } else {
        this.$message.error(userRealName.msg);
      }
      //如果设置必须实名
      // console.log(this.szrealNameAuth,'是否必须实名')
      // console.log(this.RealNameData,'是否已经实名')
      if (this.szrealNameAuth) {
        //但是没实名就false
        if (this.RealNameData) {
          this.withdrawState = false;
        } else {
          //已经实名就是true
          this.withdrawState = true;
        }
      } else {
        this.withdrawState = true;
      }
    },
    //提现按钮
    async moneyT() {
      // console.log(this.withdrawState,'002255')
      //如果满足实名条件就可以提现
      if (this.withdrawState) {
        if (!this.WithdrawalChannel) {
          this.$message({
            message: "提现通道未开通",
            type: "warning",
          });
        } else if (this.withdrawalStateData == 1) {
          //如果没有开通提现状态0开通  1关闭
          //富文本框
          // this.WithdrawalStatusShow=true;
          this.$confirm(this.richText.withdrawContent, "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
            center: true,
          })
            .then(async () => {
              // console.log(data, "执行奖励返回信息");
            })
            .catch(() => {});
        } else {
          this.withdraw = true;
          let param = {
            userId: this.userId - 0,
            tenantId: this.TenantId,
          };
          const data = await getAmountFeeInfo(param);
          console.log(data, "返回手续费");
          if (data.code == 200) {
            if (data.data) {
              this.HandlingMoneyData = data.data.feeFixed;
              this.HandlingData = data.data.feePercentage;
            } else {
              this.HandlingMoneyData = 0;
              this.HandlingData = 0;
            }
          } else {
            this.$message.error(data.msg);
          }
          const txzh = await bankAPI({ userId: this.userId });
          console.log(txzh, "获取提现账号列表");
          if (txzh.code == "200") {
            if (txzh.data) {
              this.field102Options = txzh.data; //列表赋值给下拉框
            } else {
              this.field102Options = [];
            }
          } else {
            this.$message({
              message: txzh.msg,
              type: "warning",
            });
          }
        }
      } else {
        this.realNameShow = true;
      }
    },
    // tab切换
    clickTab(num) {
      console.log(num, "切换");
      if (this.tabStatus != num) {
        this.tabStatus = num;
        this.userData();
      }
    },
    // 编辑支付宝弹窗确认
    addUserFun3(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let param = {
            accountNumber: this.form3.accountNumber,
            accountName: this.form3.name,
            withdrawalAccountType: "ALIPAY",
            userId: this.userId,
            id: this.form3.id, //支付宝账号的id
          };
          updateCapUserWithdrawalAccount(param).then((res) => {
            // console.log(res, "编辑支付宝");
            if (res.code == 200) {
              this.$message({
                message: "编辑成功",
                type: "success",
              });
              this.tanShow3 = false;
              this.userData();
            } else {
              this.$message.error("编辑失败");
            }
          });
          // 确认之后 发起请求
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 点击修改支付宝按钮
    clickModification(el) {
      // console.log(el,'66')
      this.tanShow3 = true;
      this.form3 = {
        name: el.accountName, //姓名
        userId: el.userId, //用户id
        id: el.id, //用户id
        accountNumber: el.accountNumber, //手机号
      };
      // this.form3 = { ...el };
    },
    // 点击删除银行卡或支付宝按钮函数
    clickDelete(id, num) {
      console.log(id, num, "删除");
      this.tanShow3 = false;
      this.$confirm(`是否删除${num}的账户?`, "", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteCapUserWithdrawalAccountById({ id }).then((res) => {
            // console.log(res, "删除了");
            if (res.code == 200) {
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.userData();
            } else {
              this.$message.error("删除失败");
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
      // console.log(id);
    },
    // ..获取用户信息
    async userData() {
           //获取邀请码
      const yqm = await selectByInvitationCodeIsUserId();
      // console.log(yqm, "获取邀请码");
      if (yqm.code == 200) {
        this.Invitation = yqm.msg;
      }
      // let type = "";
      // if (this.tabStatus == 1) {
      //   type = "BANKCARD";
      // } else {
      //   type = "ALIPAY";
      // }
      let param = {
        // withdrawalAccountType:type,
        userId: this.userId,
      };
      console.log(param, "数据");
      const bankData = await bankAPI(param);
      // console.log(bankData, "获取列表");
      if (bankData.code == 200) {
        if (bankData.data) {
          //如果是银行卡就截取最后4位，0是支付宝 1是银行卡
          bankData.data.forEach((item) => {
            if (item.withdrawalAccountType == "BANKCARD") {
              item.accountNumber = item.accountNumber.slice(-4);
            }
          });

          this.bank = bankData.data;
        } else {
          this.bank = [];
        }
      } else {
        this.$message.error(bankData.msg);
      }

      const data = await selectCapUserWalletById({ userId: this.userId }); //获取账户余额
      if (data.code == 200) {
        // console.log(data, "当前账户余额");
        this.amount = data.data.balance;
        this.formData.field101 = data.data.balance || 0; //提现弹窗显示的账号余额
      } else {
        this.$message.error(data.msg);
      }

     
    },

    // 添加银行卡支付宝弹窗确认
    addUserFun1(formName, type) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          let param = {};
          if (type == "BANKCARD") {
            this.fullscreenLoading = true;

            this.addBankButton = true; //点击确定之后会有延迟，禁用确定按钮

            setTimeout(() => {
              this.fullscreenLoading = false;
              this.addBankButton = false;
            }, 5000);
            // 确认之后 发起请求
            param = {
              // name: "牛阳泽", //姓名
              // idcard: "410802198309283512", //身份证号
              // accountNumber: "6217002480006284430", //银行卡号
              // phoneNumber: "15517777217", //手机号
              // userId: this.userId, //用户id
              // code:"123"

              // 分割线
              accountName: this.form1.name, //姓名
              idCard: this.form1.idCard, //身份证号
              accountNumber: this.form1.accountNumber, //银行卡号
              phoneNumber: this.form1.phoneNumber, //手机号
              userId: this.userId, //用户id
              code: this.form1.code, //验证码
              withdrawalAccountType: type, //新增支付宝还是银行卡  BANKCARD银行卡 ALIPAY支付宝
            };
            console.log(param, "添加银行卡给后端的参数");
          } else {
            setTimeout(() => {
              this.tanShow2 = false;
              this.showButton = false;
            }, 5000);
            this.tanShow2 = true;
            this.showButton = true;
            param = {
              accountNumber: this.form2.accountNumber, //支付宝账号
              accountName: this.form2.name, //支付宝姓名
              userId: this.userId,
              withdrawalAccountType: type, //新增支付宝还是银行卡  BANKCARD银行卡 ALIPAY支付宝
            };
          }
          insertCapUserWithdrawalAccountBank(param).then((res) => {
            console.log(res, "添加银行卡后端返回");
            if (res.code == 200) {
              this.ifShowTan1(false);
              this.$message({
                message: `绑定成功`,
                type: "success",
              });
              this.userData();
            } else {
              this.$message.error(res.msg);
            }
            this.fullscreenLoading = false;
            this.addBankButton = false;
            this.tanShow2 = false;
            this.showButton = false;
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //睁眼闭眼
    ShowMoney() {
      if (this.eye) {
        this.eye = false;
      } else {
        this.eye = true;
      }
    },
    //提现金额chang
    async mobileChange() {
      if (this.formData.mobile == "") {
        this.formData.HandlingMoney = 0;
      }
      console.log(this.HandlingData, "百分比");
      console.log(this.HandlingMoneyData, "固定值");
      let baifenbi = this.HandlingData * this.formData.mobile - 0;

      let baifenbibaoliuxiaoshu = this.HandlingMoneyData - 0 + baifenbi - 0;
      console.log(baifenbibaoliuxiaoshu, "百分比结果");
      console.log(this.HandlingMoneyData, "固定值结果");
      this.formData.HandlingMoney = baifenbibaoliuxiaoshu.toFixed(2); //四舍五入只保留2位小数
      this.formData.actualMoney =
        this.formData.mobile - this.formData.HandlingMoney;
    },
    //提现弹窗关闭事件
    withdrawClose() {
      this.formData.mobile = "";
      this.formData.actualMoney = "";
      this.formData.HandlingMoney = "";
      this.withdraw = false;
    },

    change() {
      this.show = !this.show;
    },

    // 获取银行卡或支付宝列表函数
    gutUserWithdrawalAccountSelectBankFun() {
      let data = {
        pageNum: 1,
        pageSize: 6,
      };
      if (this.tabStatus == 1) {
        selectByPageNumSizeTxList(data).then((res) => {
          // console.log(res, "58525852");
          if (res.code == 200) {
            this.bank = res.data.list;
            console.log(this.bank);
          }
        });
        gutUserWithdrawalAccountSelectBankInfo(this.userId).then((res) => {
          // console.log(res,'2222222')
          this.bank1 = res.data;
        });
      } else if (this.tabStatus == 2) {
        gutUserWithdrawalAccountSelectAlipay(this.userId)
          .then((data) => {
            // if (data.code == 200) {
            console.log(data);
            this.Alipay = data;
            // } else {
            //   this.$message.error(data.msg);
            // }
          })
          .catch(() => {
            this.$message.error("获取支付宝列表失败");
          });
      }
    },
    // 重置银行卡数据 函数
    resetDataFun1() {
      this.form1.name = undefined;
      this.form1.phoneNumber = undefined;
      this.form1.idCard = undefined;
      this.form1.code = undefined;
      this.form1.accountNumber = undefined;
      this.timerFunEnd();
    },
    // 重置支付宝数据 函数
    resetDataFun2() {
      this.form2.name = undefined;
      this.form2.accountNumber = undefined;
      this.timerFunEnd();
    },
    // 关闭定时器
    timerFunEnd() {
      this.gain.title = "获取验证码";
      this.gain.flag = false;
      clearInterval(this.timer);
    },
    // 定时器
    timerFun() {
      this.gain.flag = true;
      let timerNum = 60;
      this.gain.title = timerNum + "秒后重试";

      this.timer = setInterval(() => {
        timerNum--;
        console.log(11);
        if (timerNum < 0) {
          this.timerFunEnd();
        } else {
          this.gain.title = timerNum + "秒后重试";
        }
      }, 1000);
    },

    // 添加银行卡弹窗控制
    ifShowTan1(flag) {
      this.tanShow1 = flag;
      // this.resetDataFun1();
    },
    // 添加支付宝弹窗控制
    ifShowTan2(flag, flag3) {
      this.tanShow2 = flag;
      this.tanShow3 = flag3 ? flag3 : false;
      this.resetDataFun2();
    },

    // 发送短信验证码
    sendCodeFun(el) {
      console.log(this[el].phoneNumber);
      if (
        this[el].phoneNumber &&
        this[el].phoneNumber.length == 11 &&
        /^[1][3.4.5.7.8.9][0-9]{9}$/.test(this[el].phoneNumber)
      ) {
        this.timerFun();
        // console.log(this[el].phoneNumber);
                let data = {
        phone: this[el].phoneNumber,
        // phone: '17639181867',
        url: this.Invitation,
      };

        // let data = {
        //   phone: this[el].phoneNumber,
        //   userId: this.userId,
        // };
        console.log(data, "发送手机验证码给后端的参数");
        getAliDy1(data).then((data) => {
          console.log(data);
          if (data.code == 200) {
            this.sendCodeFlag = true;
          } else {
            this.$message.error(data.msg);
          }
        });
        // console.log("发送验证码");
      }
    },
    // 提现发送短信验证码
    withdrawSendCodeFun() {
      console.log(this.phoneData);
      if (
        this.phoneData.length == 11 &&
        /^[1][3.4.5.7.8.9][0-9]{9}$/.test(this.phoneData)
      ) {
        this.timerFun2();
        // let data = {
        //   phone: this.phoneData,
        //   userId: this.userId,
        // };
           let data = {
        phone:this.phoneData,
        // phone: '17639181867',
        url: this.Invitation,
      };

        console.log(data, "发送手机验证码给后端的参数");
        //佳宾的验证码
        getAliDy1(data).then((data) => {
          console.log(data);
          if (data.code == 200) {
            this.sendCodeFlag = true;
          } else {
            this.$message.error(data.msg);
          }
        });
          //职凯的验证码
        // Verification(data).then((data) => {
        //   console.log(data);
        //   if (data.code == 200) {
        //     this.sendCodeFlag = true;
        //   } else {
        //     this.$message.error(data.msg);
        //   }
        // });
        // console.log("发送验证码");
      }
    },
    // 关闭定时器
    timerFunEnd2() {
      this.fixed.title = "获取验证码";
      this.fixed.flag = false;
      clearInterval(this.timer);
    },
    // 定时器
    timerFun2() {
      this.fixed.flag = true;
      let timerNum = 60;
      this.fixed.title = timerNum + "秒后重试";

      this.timer = setInterval(() => {
        timerNum--;
        console.log(11);
        if (timerNum < 0) {
          this.timerFunEnd2();
        } else {
          this.fixed.title = timerNum + "秒后重试";
        }
      }, 1000);
    },
  },
  computed: {
    submitMoneyButton() {
      if (this.formData.actualMoney <= 0) {
        return true;
      } else {
        return false;
      }
    },
  },
};
</script>
<style>
body .el-scrollbar__wrap {
  overflow-x: hidden;
  /* //隐藏横向滚动条   */
}
</style>
<style scoped lang="scss">
// 弹窗在屏幕居中
::v-deep .el-dialog__wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}
::v-deep .el-dialog:not(.is-fullscreen) {
  margin-top: 0vh !important;
}
//原来这是全局的样式,现在放在里面了,目前还没看出来有什么异常
.el-select-dropdown .el-scrollbar .el-scrollbar__wrap {
  overflow: scroll !important;
}

.bank,
.bankBox,
.Alipay {
  border-radius: 20px;
  padding: 40px 20px;
  font-size: 20px;
  height: 210px;
  img {
    width: 50px;
    position: relative;
  }
  .fontSize {
    font-size: 15px;
  }
}
.Alipay {
  background-color: rgb(63, 119, 214);
  color: #fff;
  font-weight: 100;
  .fontSize {
    color: #fff;
    font-weight: 100;
    text-decoration: none;
  }
}

.bankBox {
  // border: 1px #eee solid;
  // background: rgb(231, 228, 231);
  // background: rgb(243, 66, 43);
  background: rgb(235, 78, 69);
  font-weight: 100;
  .aaBox {
    border-radius: 50%;
    overflow: hidden;
    height: 45px;
    width: 45px;
    background: #ffffff;
    .aa {
      width: 35px;
      margin: 13px 5px;
      height: 20px;
      // border: 1px red solid;
      background: url("../../../assets/img/ylbt.png") no-repeat center;
      background-size: 100% 100%;
    }
  }
  .fontSize {
    color: #fff;
    font-weight: 100;
    text-decoration: none;
  }
}

.bankimgtb {
  border-radius: 50%;
  overflow: hidden;
  height: 50px;
  background: #ffffff;
  .aa {
    width: 40px;
    margin: 13px 5px;
    height: 25px;
    // border: 1px red solid;
    background: url("../../../assets/img/ylbt.png") no-repeat center;
    background-size: 100% 100%;
  }

  img {
    // height: 25px;
    margin-top: 10px;
  }
}
.buttonBox {
  button {
    color: #3875f6;
    background: rgba(56, 117, 246, 0.1);
  }
  button:hover {
    color: rgb(229, 229, 229);
    background: #3875f6;
  }
}
.accoutTop-left {
  // border: 1px red solid;
}
.accoutTop-right {
  margin-left: 200px;
  .accountBox {
  }
  //  border: 1px red solid;
}
.rightbox {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.iconbox {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgba(255, 255, 240, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 5px;
  margin-bottom: 4px;
}
.deletedIcon {
  position: absolute;
  z-index: 10;
}
.line-bottom {
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
  margin-bottom: 20px;
}
.line-bottom2 {
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
  margin-bottom: 20px;
}
.line-bottom1 {
  // border-bottom: 1px solid #eee;
  padding-bottom: 20px;
  margin-bottom: 20px;
}
.el-avatar {
  border: 3px solid #5ba5fc40;
}
.account-title {
  font-weight: 400;
  font-size: 18px;
}
.accoutTop {
  display: flex;
  align-content: center;
  padding: 10px 20px;
}
.accoutTop-left {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding-left: 20px;
}
.accountName {
  color: #333;
  font-size: 20px;
  margin-right: 10px;
}
.color66 {
  color: #666666;
}
.accountPhone {
  margin-right: 10px;
  color: #333;
}
.el-avatar {
  border: 3px solid #fff;
}
.account-title {
  font-weight: 500;
  font-size: 20px;
}
.accoutTop {
  display: flex;
  align-content: center;
  padding: 10px 20px;
}
.accoutTop-left {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding-left: 20px;
}
.accountName {
  color: #333;
  font-size: 24px;
  margin-right: 20px;
}
.color66 {
  color: #666666;
}
.accountPhone {
  color: #333;
  display: flex;
  align-items: center;
  // border: 1px red solid;
}

.myAccount2 {
  padding: 20px;
  .topDiv {
    border: none;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(220, 223, 230, 1);
    border-radius: 10px;
    height: auto;
    padding: 20px;
    // & > div {
    //   // padding: 20px;
    //   // height: 807px;
    //   height: auto;
    //   overflow-x: hidden;
    //   overflow-y: auto;
    //   background-color: #fff;
    //   // margin-right: -15px;
    // }
    .title {
      border: none;
      margin: 0;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      img {
        width: 30px;
        height: 30px;
        margin-right: 5px;
      }
    }
  }
  .topDiv2 {
    border: none;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(220, 223, 230, 1);
    border-radius: 10px;
    height: 86vh;
    padding: 20px;
    .title {
      border: none;
      margin: 0;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      img {
        width: 30px;
        height: 30px;
        margin-right: 5px;
      }
    }
  }
  .account {
    p {
      font-size: 20px;
    }
  }

  .addBank,
  .addAlipay {
    border-radius: 20px;
    background-color: rgba(0, 0, 0, 0);
    height: 210px;
    border: 1px dashed #409eff;
    position: relative;
    & > div {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translateX(-50%) translateY(-50%);
      button {
        font-size: 20px;
        i {
          margin-bottom: 10px;
        }
      }
    }
  }
  .bank {
    background-color: rgb(229, 229, 229);
    color: rgb(79, 79, 79);

    height: 210px;
  }

  .hint {
    position: relative;
    // border: 1px red solid;
    color: #fff;
    width: 100%;
    .card-type {
      width: 68px;
      height: 28px;
      background: url("../../../assets/img/card-bg.png") no-repeat center center;
      background-size: cover;
      color: #ffffff;
      // display: flex;
      // justify-content: center;
      // align-items: center;
      text-align: center;
      .name {
        font-size: 16px;
        margin-left: 5px;
      }
    }
  }
}
</style>

